/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import org.eclipse.persistence.annotations.CascadeOnDelete;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "ACT")
@XmlRootElement
public class ACT implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "actID")
    private Integer actid;
    @JoinColumn(name = "actCust", referencedColumnName = "CId")
    @ManyToOne(optional = false)
    private Customer actCustomer;
    @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
    @CascadeOnDelete
    @JoinTable(
        name="JTACT",
        joinColumns={ @JoinColumn(name="actID", referencedColumnName="actID")},
        inverseJoinColumns={ @JoinColumn(name="acbID", referencedColumnName="acbID", unique=true)}
    )
    private List<ACB> acbCollection;

    public ACT() {
    }

    public ACT(Integer acbid) {
        this.actid = acbid;
    }

    public Integer getACTID() {
        return actid;
    }

    public void setACTID(Integer actid) {
        this.actid = actid;
    }
    
    public Customer getACTCustomer(){
        return actCustomer;
    }
    
    public void setACTCustomer(Customer actCustomer){
        this.actCustomer = actCustomer;
    }

    public List<ACB> getACBCollection() {
        return acbCollection;
    }

    public void setACBCollection(List<ACB> acbCollection) {
        this.acbCollection = acbCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (actid != null ? actid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sales)) {
            return false;
        }
        ACT other = (ACT) object;
        if ((this.actid == null && other.actid != null) || (this.actid != null && !this.actid.equals(other.actid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.ACT[ actid=" + actid + " ]";
    }
    
}
